﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebNext.Domain;
using WebNext.Domain.Entities;

namespace WebNext.UI.Utils.Validators
{
	public class UserNameValidator : IValidator
	{
		private string userName;

		public UserNameValidator(string userName)
		{
			this.userName = userName;
		}

		public virtual ValidationResult Validate()
		{
			ValidationResult result = new ValidationResult();

			if (string.IsNullOrWhiteSpace(this.userName))
			{
				result.AddError(Properties.Resources.UserNameCannotBeEmpty);
			}
			else if (this.userName.Length < AdminSettings.MinUserNameLength)
			{
				result.AddError(Properties.Resources.UserNameTooShort, AdminSettings.MaxUserNameLength);
			}
			else if (this.userName.Length > AdminSettings.MaxUserNameLength)
			{
				result.AddError(Properties.Resources.UserNameTooLong, AdminSettings.MaxUserNameLength);
			}

			return result;
		}
	}
}